/*
 * Created on Feb 22, 2007 by mbruns
 * Project MultilingualBVMC
 * Package com.broadvision.bvgs.multilang.action
 * TODO 
 */
package com.broadvision.bvgs.multilang.action;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.DynaValidatorForm;

import com.broadvision.bvgs.multilang.MultilangUtils;
import com.broadvision.data.client.Content;

public class PageTypeMultilangAddAction extends PageTypeMultilangViewAction {

    
        public ActionForward processExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
            throws Exception
                {
                        System.out.println("entering into class: "+ this.getClass());
                        System.out.println("calling updateMultilang()" );
        	
        				updateMultilang(request, form);
                        Map contextParams = prepareContextParams(request);
                        request.setAttribute("pagetabParam", contextParams);
                        prepareTab(request);
                        return super.processExecute(mapping,form,request, response);
                }
                
                protected void updateMultilang(HttpServletRequest request, ActionForm form){
                	
                	System.out.println("inside updateMultilang()" );
                        String language = ((DynaValidatorForm) form).getString("language");
                        String text = ((DynaValidatorForm) form).getString("text");
                        
                        System.out.println("language===="+ language);
                        System.out.println("text===="+ text);
                        
                        System.out.println("calling getContentToTranslate()");
                        Content content = getContentToTranslate(request);
                        
                        System.out.println("calling addMultilangName()");
                        MultilangUtils.addMultilangName(content, language, text, getTranslationTableName(), getTranslationLanguageFieldName(), getTranslationNameFieldName());
                }

}
